{SysSrv} = require "./SysSrv"

SupperClzz = SysSrv
exports.Role_rigAddSrv = new Class
  Extends: SupperClzz
  options:
    tab: "role_rig"
    $vdts: ["role_id","menu_id"]
  role_rigVdt: (reqOpt,key,val,id,eny)->
    t = this
    o = t.options
    if !val
      return {err:"角色不能为空!"}
    true
  role_rigVdt: (reqOpt,key,val,id,eny)->
    t = this
    o = t.options
    if !val
      return {err:"菜单不能为空!"}
    true
  confirmButClk: (reqOpt,entry,keyArr,returning,tab)->
    t = this
    o = t.options
    rltSet = undefined
    rltSet0 = yield t.callSql reqOpt,"select * from role_rig where role_id=$1 and menu_id=$2",[entry.role_id,entry.menu_id]
    eny = rltSet0.rows[0]
    if !eny
      rltSet = yield SupperClzz.prototype.confirmButClk.apply t,arguments
    else
      entry.id = eny.id
      keyArr.erase "role_id"
      keyArr.erase "menu_id"
      rltSet = yield t.update reqOpt,entry,keyArr,returning,tab
    rltSet